package com.example.coursehub.service;

import java.util.List;
import com.example.coursehub.dto.*;
import com.example.coursehub.entity.*;
import org.springframework.transaction.annotation.Transactional;

public interface ExerciseService {
    Exercise createExercise(Exercise exercise);// 创建练习

    void deleteExercise(String exerciseId);// 删除练习

    Exercise getExerciseById(String exerciseId);// 根据id获取练习

    List<Exercise> getUnfinishedExercises(String courseId, String userId);// 获取未完成的练习

    List<Question> getExerciseQuestions(String exerciseId);// 获取练习下的题目
    ExerciseDetailDTO getExerciseDetail(String exerciseId, String userId);
    List<Exercise> getFinishedExercises(String courseId, String userId);// 获取已完成的练习

    List<Question> getFavoriteQuestionBank(String userId, String courseId);// 获取收藏的题目

    List<Question> getWrongQuestionBank(String userId, String courseId);// 获取错题集

    void submittedExercise(StudentExercise studentExercise, List<StudentQuestionAnswer> studentQuestionAnswers);// 提交练习

    void addFavoriteQuestion(String userId, String courseId, String questionId);// 添加收藏题目

    void removeFavoriteQuestion(String userId, String courseId, String questionId);// 移除收藏题目

    List<Exercise> getAllCourseExercises(String courseId);// 获取课程下所有练习

    List<Exercise> getAllClassExercises(String classId);

    List<StudentExercise> getAllStudentExercise(String exerciseId);//获取练习下所有学生练习

    List<StudentQuestionAnswer> getAllStudentQuestionAnswer(String exerciseId,String studentId);//对应学生的对应练习的对应的答案
    Exercise createExerciseWithQuestions(ExerciseCreateDTO dto);

    List<StudentExerciseWithDetailsDTO> getClassExercisesForGrading(String classesId);

    ExerciseDetailDTO getStudentExerciseForGrading(String exerciseId, String studentId);

    @Transactional
    void submitGrades(GradeSubmissionDTO gradeSubmission);

    @Transactional
    void deleteExerciseWithCascade(String exerciseId);

    List<Question> loadCourseQuestionBank(String courseId);

    @Transactional
    Question addQuestionToCourseBank(Question question, String courseId);

    @Transactional
    void deleteQuestionFromCourseBank(String questionId, String courseId);

    int calculateStudentRank(StudentExercise studentExercise);

    // ====================== 新增函数 1：根据课程ID和用户ID获取班级ID ======================
    String getClassesIdByCourseAndUser(String courseId, String userId);

    // ====================== 新增函数 2：根据课程ID和用户ID获取身份 ======================
    String getUserRoleByCourseAndUser(String courseId, String userId);

    List<Exercise> getClassExercises(String classId);

    List<Classes> getClassesAsTeacher(String courseId, String userId);
}